/* Base styles optimized for iframe and mobile-first design */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    height: 100vh;
    overflow-x: hidden;
}

/* Main game container - responsive height */
.game-container {
    width: 100%;
    height: 450px; /* Default iframe height */
    max-width: 1200px;
    margin: 0 auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
}

/* Detect if running in new tab vs iframe */
@media (min-height: 600px) {
    .game-container {
        height: 90vh;
        padding: 12px;
        gap: 12px;
    }
}

/* Resource Dashboard - Always visible at top */
.resource-dashboard {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    background: rgba(255, 255, 255, 0.95);
    padding: 12px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
}

.resource-item {
    text-align: center;
    cursor: help;
    transition: transform 0.2s ease;
}

.resource-item:hover {
    transform: translateY(-2px);
}

.resource-label {
    display: block;
    font-size: 0.8em;
    color: #666;
    font-weight: 500;
}

.resource-value {
    display: block;
    font-size: 1.1em;
    font-weight: bold;
    color: #2c3e50;
    margin-top: 2px;
}

/* Worker Pool */
.worker-pool {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.9);
    padding: 8px 16px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.worker-pool-label {
    font-weight: 600;
    color: #2c3e50;
    font-size: 0.9em;
    cursor: help;
}

.workers {
    display: flex;
    gap: 8px;
}

.worker {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 1.2em;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.worker.available {
    background: linear-gradient(45deg, #4CAF50, #45a049);
    box-shadow: 0 2px 6px rgba(76, 175, 80, 0.3);
}

.worker.used {
    background: #bdc3c7;
    opacity: 0.6;
    transform: scale(0.9);
}

/* National Sectors Grid */
.sectors-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 8px;
    flex: 1;
}

.sector-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    min-height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.sector-card:hover:not(.filled) {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    border-color: #3498db;
}

.sector-card.filled {
    background: #ecf0f1;
    cursor: not-allowed;
    opacity: 0.7;
    border-color: #95a5a6;
}

.sector-name {
    font-weight: 600;
    font-size: 0.85em;
    color: #2c3e50;
    line-height: 1.2;
    margin-bottom: 4px;
}

.sector-reward {
    font-size: 0.8em;
    color: #27ae60;
    font-weight: 500;
}

/* National Priorities Section */
.priorities-section {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.priorities-header {
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 8px;
    text-align: center;
    font-size: 1em;
    cursor: help;
}

.priorities-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 8px;
}

.priority-card {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 8px;
    padding: 10px;
    border: 1px solid #dee2e6;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.priority-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.priority-title {
    font-weight: 600;
    font-size: 0.85em;
    color: #2c3e50;
    margin-bottom: 4px;
    line-height: 1.2;
}

.priority-category {
    font-size: 0.7em;
    color: #6c757d;
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.priority-helps {
    font-size: 0.7em;
    color: #495057;
    margin-bottom: 4px;
}

.priority-cost {
    font-size: 0.75em;
    color: #e74c3c;
    font-weight: 500;
    margin-bottom: 2px;
}

.priority-reward {
    font-size: 0.75em;
    color: #27ae60;
    font-weight: 500;
    margin-bottom: 6px;
}

.fund-button {
    width: 100%;
    padding: 6px 8px;
    background: linear-gradient(45deg, #3498db, #2980b9);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.75em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.fund-button:hover:not(:disabled) {
    background: linear-gradient(45deg, #2980b9, #1f5f8b);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(52, 152, 219, 0.3);
}

.fund-button:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* End Turn Section */
.end-turn-section {
    display: flex;
    justify-content: center;
    padding: 8px 0;
}

.end-turn-button {
    padding: 12px 24px;
    background: linear-gradient(45deg, #e74c3c, #c0392b);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}

.end-turn-button:hover:not(:disabled) {
    background: linear-gradient(45deg, #c0392b, #a93226);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(231, 76, 60, 0.4);
}

.end-turn-button:disabled {
    background: #95a5a6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 600px; /* Increased width for decision summary */
    max-height: 85vh; /* Added max height for scrolling */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
    overflow-y: auto; /* Added scrolling for long content */
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 16px 20px;
    border-radius: 12px 12px 0 0;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.3em;
    font-weight: 600;
}

.modal-body {
    padding: 20px;
    text-align: center;
}

.modal-body p {
    margin-bottom: 12px;
    line-height: 1.5;
    color: #2c3e50;
}

.final-score {
    font-size: 2em;
    font-weight: bold;
    color: #27ae60;
    margin: 16px 0;
    text-shadow: 0 2px 4px rgba(39, 174, 96, 0.3);
}

/* Added: Decision Summary Styles */
.decision-summary {
    margin-top: 24px;
    text-align: left;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 16px;
    border: 1px solid #dee2e6;
}

.decision-summary h3 {
    color: #2c3e50;
    font-size: 1.1em;
    margin-bottom: 16px;
    text-align: center;
    border-bottom: 2px solid #3498db;
    padding-bottom: 8px;
}

.summary-section {
    margin-bottom: 16px;
}

.summary-section h4 {
    color: #34495e;
    font-size: 0.95em;
    margin-bottom: 8px;
    font-weight: 600;
}

.funded-projects-list {
    background: white;
    border-radius: 6px;
    padding: 8px;
    border: 1px solid #e9ecef;
}

.project-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    margin-bottom: 4px;
    background: linear-gradient(135deg, #f1f3f4, #e8eaf6);
    border-radius: 4px;
    border-left: 3px solid #3498db;
}

.project-item:last-child {
    margin-bottom: 0;
}

.project-name {
    font-weight: 500;
    color: #2c3e50;
    font-size: 0.85em;
}

.project-nwp {
    color: #27ae60;
    font-weight: 600;
    font-size: 0.8em;
}

.deployment-summary, .resource-summary {
    background: white;
    border-radius: 6px;
    padding: 8px;
    border: 1px solid #e9ecef;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 4px 8px;
    font-size: 0.85em;
    color: #495057;
}

.stat-value {
    font-weight: 600;
    color: #2c3e50;
}

.no-projects {
    color: #6c757d;
    font-style: italic;
    text-align: center;
    padding: 12px;
    font-size: 0.85em;
}

.modal-footer {
    padding: 16px 20px;
    text-align: center;
    border-top: 1px solid #ecf0f1;
}

.modal-button {
    padding: 10px 20px;
    background: linear-gradient(45deg, #3498db, #2980b9);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.modal-button:hover {
    background: linear-gradient(45deg, #2980b9, #1f5f8b);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

/* Tooltip Styles */
.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.8em;
    max-width: 250px;
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
}

.tooltip.show {
    opacity: 1;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .game-container {
        padding: 6px;
        gap: 6px;
    }
    
    .resource-dashboard {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
        padding: 8px;
    }
    
    .sectors-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }
    
    .priorities-grid {
        grid-template-columns: 1fr;
        gap: 6px;
    }
    
    .worker-pool {
        padding: 6px 12px;
        gap: 8px;
    }
    
    .worker {
        width: 28px;
        height: 28px;
        font-size: 1em;
    }
    
    .modal-content {
        width: 95%;
        margin: 5% auto;
        max-width: 95%;
    }
    
    /* Mobile adjustments for decision summary */
    .decision-summary {
        padding: 12px;
    }
    
    .project-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .project-nwp {
        align-self: flex-end;
    }
}

/* Touch target optimization for mobile */
@media (pointer: coarse) {
    .sector-card {
        min-height: 90px;
        padding: 14px;
    }
    
    .fund-button {
        padding: 8px 10px;
        font-size: 0.8em;
    }
    
    .end-turn-button {
        padding: 14px 28px;
        font-size: 1em;
    }
}